﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SolutionModel;
using SFast.DB;
using SolutionDAL;

namespace SolutionBLL
{
    public class T_AdminRolesBLL
    {

        #region 检查数据库中是否已经存在某角色名称
        /// <summary>
        /// 检查数据库中是否已经存在某角色名称
        /// </summary>
        /// <param name="RolesName">当前需要验证的角色名称</param>
        /// <returns></returns>
        public int HasRolesName(String RolesName, String id)
        {
            T_AdminRolesDAL dal = new T_AdminRolesDAL();
            return dal.HasRolesName(RolesName, id);
        }
        #endregion

        #region 添加角色
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="obj"></param>
        public void InsertAdminRoles(T_AdminRole obj)
        {
            T_AdminRolesDAL dal = new T_AdminRolesDAL();
            dal.InsertAdminRoles(obj);
        }
        #endregion

        #region 获取角色列表(有页面大小)
        /// <summary>
        /// 获取角色列表(有页面大小)
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        public Pagination<T_AdminRole> GetAdminRolesList(int size)
        {
            T_AdminRolesDAL dal = new T_AdminRolesDAL();
            return dal.GetAdminRolesList()._ToPagination(size);
        }
        #endregion

        #region 获取所有角色列表
        /// <summary>
        /// 获取所有角色列表
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        public List<T_AdminRole> GetAdminRolesList(String roleNameKey)
        {
            T_AdminRolesDAL dal = new T_AdminRolesDAL();
            var q = dal.GetAdminRolesList();
            q = q.Where(o => o.RoleName.Contains(roleNameKey));
            return q.ToList();
        }
        #endregion

        #region 通过IsDisabled 来获取角色，true为启动  false 为禁用
        /// <summary>
        /// 通过IsDisabled 来获取角色，true为启动  false 为禁用
        /// </summary>
        /// <param name="isd"></param>
        /// <returns></returns>
        public List<T_AdminRole> Get_AdminRolesList_By_IsDisabled(bool isd, String key=null)
        {
            T_AdminRolesDAL dal = new T_AdminRolesDAL();
            return dal.Get_AdminRolesList_By_IsDisabled(isd, key);
        }
        #endregion

        #region 通过角色ID获取角色信息，返回回填表单的js
        /// <summary>
        /// 通过角色ID获取角色信息，返回回填表单的js
        /// 标记：要修改 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public void GetAdminRolesByIDToJs(String id)
        {
            T_AdminRolesDAL dal = new T_AdminRolesDAL();
            dal.GetAdminRolesByIDToJs(id);
        }
        #endregion

        #region 更新管理员角色
        /// <summary>
        /// 更新管理员角色
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int UpdateAdminRoles(T_AdminRole obj)
        {
            T_AdminRolesDAL dal = new T_AdminRolesDAL();
            return dal.UpdateAdminRoles(obj);
        }
        #endregion

    }
}
